package servlet.post;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;

/**
 * Create By IntelliJ IDEA
 *
 * @Author: jsonor
 * @Create-Time: 2017/9/26 11:23
 * @Description: post消息
 */
public class PostServlet extends HttpServlet {

  private static final Logger logger = Logger.getLogger(PostServlet.class);


  @Override
  protected void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    doPost(req, resp);
  }

  /**
   * 获取Post方法，并且进行解析
   * @param req 请求
   * @param resp 响应
   * @throws ServletException
   * @throws IOException
   */
  @Override
  protected void doPost(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    // 对于get方法，如果需要获取url后面的参数（key=value），可以通过调用
    // req.getParameter(key)，返回对应的value


    String name = req.getParameter("name");
    logger.warn(name);
  }
}
